XML := ../AnalyseurXML/
DTD := ../AnalyseurDTD/

BIN := bin/
TEST := test/

CXX := g++
CXXFLAGS := -Wall

MODULES	:= dtdvalidator #document doctype_definition
OBJS=$(patsubst %,$(OBJDIR)%.o,$(MODULES))

all: $(BIN)final

$(BIN)final: main.c xsltransformer.cpp $(XML)src/*.l $(XML)src/*.y makefile $(OBJS)
	make -C $(XML)src gen
	make -C $(DTD)src gen
	$(CXX) $(CXXFLAGS) -g -DYYDEBUG=1 -o $(BIN)final  main.c $(XML)gen/lex.xml.c $(XML)gen/xml.tab.c xsltransformer.cpp $(XML)bin/*.o $(DTD)gen/lex.dtd.c  $(DTD)gen/dtd.tab.c $(DTD)bin/*.o $(OBJS)
	chmod a+x $(BIN)final

#dtdvalidator requires C++11
%.o: %.cpp %.h
	@echo "compilation de "$<
	$(CXX) $(CXXFLAGS) -c -std=c++11 $< -o $@;
	@echo ""

clean:
	make -C $(XML)src clean
	make -C $(DTD)src clean
	rm $(BIN)final

#can't use the target 'test' as there's a folder named like this
tests:
	#make -C $(DTD)src test
	@cd $(TEST); ./test.sh

